. "$builders_dir_root/libvpx/tmp.kludge0.sh"

pkg_name=libvpx
version=1.4.0
src_dir=$src_dir_root/$pkg_name-$version
archive_name=v$version.tar.gz
url=https://github.com/webmproject/$pkg_name/archive/$archive_name

cd "$src_dir_root"
rm -Rf "$pkg_name-$version"
tar zxf "$archive_name"

cd "$src_dir"

#fixing usual perl diareha
sed -i 's:#!/usr/bin/env perl:#!/libexec/libvpx-perl/bin/perl:' ./build/make/ads2gas.pl
sed -i 's:#!/usr/bin/env perl:#!/libexec/libvpx-perl/bin/perl:' ./build/make/ads2gas_apple.pl
sed -i 's:#!/usr/bin/env perl:#!/libexec/libvpx-perl/bin/perl:' ./build/make/ads2armasm_ms.pl
sed -i 's:#!/usr/bin/env perl:#!/libexec/libvpx-perl/bin/perl:' ./build/make/rtcd.pl
sed -i '592,+2 d' ./build/make/configure.sh

OLD_PATH=$PATH
PATH=/libexec/libvpx-perl/bin:$PATH
"./configure"				\
	--prefix=/			\
	--target=x86_64-linux-gcc	\
	--disable-debug			\
	--disable-gprof			\
	--disable-gcov			\
	--disable-examples		\
	--disable-docs			\
	--disable-unit-tests		\
	--disable-decode-perf-tests	\
	--disable-encode-perf-tests	\
	--as=yasm			\
	--disable-codec-srcs		\
	--disable-debug-libs		\
	--enable-vp9-highbitdepth	\
	--enable-vp8			\
	--enable-vp9			\
	--disable-internal-stats	\
	--disable-mem-tracker		\
	--enable-multithread		\
	--enable-runtime-cpu-detect	\
	--enable-shared			\
	--disable-static		\
	--disable-small			\
	--enable-multi-res-encoding	\
	--disable-webm-io		\
	--disable-libyuv		\
	--disable-vp8-decoder		\
	--disable-vp9-decoder
	
export CFLAGS=-O0
make
unset CFLAGS

install_tmp_dir=/tmp/$pkg_name-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"
make install "DESTDIR=$install_tmp_dir"
export PATH=$OLD_PATH

install_dirs "$builders_dir_root/$pkg_name/runtime.dirs"
install_files "$builders_dir_root/$pkg_name/runtime.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/runtime.links"
install_dirs "$builders_dir_root/$pkg_name/devel.dirs"
install_files "$builders_dir_root/$pkg_name/devel.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/devel.links"
elf_strip "$builders_dir_root/$pkg_name/elf-strip"

rm -Rf "$install_tmp_dir"
rm -Rf "$src_dir"

remove_files "$builders_dir_root/libvpx/tmp.kludge0.files"
remove_files "$builders_dir_root/libvpx/tmp.kludge0.links"
remove_dirs "$builders_dir_root/libvpx/tmp.kludge0.dirs"
